/*
 * ActivityMessageHolder.java
 * business
 *
 * Created by chentao on 2017/4/26.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.ui.widget.listview.ViewHolder;
import com.yidiandao.business.utils.ImageLoader;

/**
 * 活动通知
 * <p>
 * Created by ChenTao(chentao7v@gmail.com) on 2017/4/26 0026 9:11
 */
public class ActivityMessageHolder extends ViewHolder {

    public RelativeLayout rootLayout;

    private ImageView ivImage;

    private TextView tvTitle;

    private TextView tvContent;

    private ImageView ivNext;

    private TextView tvUnreadCount;


    @Override
    protected void initView(View rootView) {
        rootLayout = (RelativeLayout) rootView.findViewById(R.id.root_layout);
        ivImage = (ImageView) rootView.findViewById(R.id.iv_image);
        tvTitle = (TextView) rootView.findViewById(R.id.tv_title);
        tvContent = (TextView) rootView.findViewById(R.id.tv_content);
        ivNext = (ImageView) rootView.findViewById(R.id.iv_next);
        tvUnreadCount = (TextView) rootView.findViewById(R.id.tv_unread_count);

        initActivityMessageUI();
    }

    private void initActivityMessageUI() {
        ImageLoader.loadLocalImage(mContext, ivImage, R.mipmap.ic_activity_message);
        tvContent.setText(R.string.click_to_see_activity_messages);
        tvTitle.setText(R.string.activity_message);
    }


    @Override
    protected int getItemLayoutId() {
        return R.layout.item_message_count;
    }

    public void refreshUnReadCount(int unReadCount) {
        if (unReadCount <= 0) {
            tvUnreadCount.setVisibility(View.GONE);
            return;
        }

        tvUnreadCount.setVisibility(View.VISIBLE);
        if (unReadCount <= 99) {
            tvUnreadCount.setText(unReadCount + "");
            return;
        }

        tvUnreadCount.setText("99+");
    }
}
